package com.roc.util;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;

import org.apache.commons.lang3.StringUtils;

public enum OrderType {

	FIRST_QUERY("1000","查询"),
	SECOND_QUERY("1001","二次查询"),	
	FIRST_SURVEY("1002","调单"),	
	SECOND_SURVEY("1003","二次调单"),
	LOAN_ADJUST("1004","贷记调整"),	
	FIRST_WITHDRAW_CASH("1005","请款"),
	FIRST_CHARGEBACK("1006","退单"),
	SECOND_WITHDRAW_CASH("1007","再请款"),
	SECOND_CHARGEBACK("1008",	"二次退单"),
	EXCEPTION_NEGOTIATE("1009","例外协商"),
	EXCEPTION_LONG_MONEY("1010","例外长款"),
	COLLECTION_WITHDRAW_CASH("1011","托收请款"),
	COLLECTION_NEGOTIATE("1012","托收协商"),;
		
		 
		
		 
		private String code;
		private String name;
		
		private OrderType( String code,String name) {
			this.code = code;
			this.name = name;
			
		}


		public String getCode() {
			return code;
		}

		public String getName() {
			return name;
		}

		public static OrderType valueOfCode(String code) {
			if (StringUtils.isBlank(code)) {
				throw new IllegalArgumentException("SysLogType code " + code
						+ " is OrderType");
			}
			for (OrderType ch : values()) {
				if (ch.getCode().equals(code)) {
					return ch;
				}
			}
			throw new IllegalArgumentException("SysLogType code " + code
					+ " is not exist");
		}

		/**
		 * 获取所有的枚举,以MAP返回
		 * @return
		 */
		public static HashMap<String,String> getAllEnumMap() {
			
			HashMap<String,String> map = new HashMap<String,String>();
			
			for (OrderType ch : values()) {
				map.put(ch.getCode(), ch.getName());
			}
			
			return map;
			
		}
		/**
		 * 获取所有的枚举,以现有顺序换回
		 * @return
		 */
		public static LinkedHashMap<String, String> getAllEnumLinkedHashMap() {
			
			LinkedHashMap<String,String> map = new LinkedHashMap<String,String>();
			
			for (OrderType ch : values()) {
				map.put(ch.getCode(), ch.getName());
			}
			
			return map;
			
		}
		
		public static void main(String[] args) {
			LinkedHashMap<String,String> map = new LinkedHashMap<String,String>();
			map = getAllEnumLinkedHashMap();
			System.out.println(map);
		}
	

}
